profiler: allow using gdk profiler functions without braces
authorChristian Hergert <chergert@redhat.com>
Tue, 2 Feb 2021 22:41:23 +0000 (14:41 -0800)
committerChristian Hergert <chergert@redhat.com>
Mon, 8 Feb 2021 19:29:32 +0000 (11:29 -0800)
Just compiling these out means you have to write code slightly differently
so that you don't end up with "if ();" afterwards.

This adds a "do {} while (0)" so that we're still semantically a statement
but will also compile out.

gdk/gdkprofilerprivate.h

index bd04850d9dd9b5805ea2b3930ef4cffd41cdd07c..897f4f804eea2755a356a62d6e19657bb4d4cbf3 100644 (file)
@@ -73,23 +73,23 @@ void    gdk_profiler_set_int_counter    (guint  id,
                                          gint64 value);
 
 #ifndef HAVE_SYSPROF
-#define gdk_profiler_add_mark(b, d, n, m)
-#define gdk_profiler_end_mark(b, n, m)
+#define gdk_profiler_add_mark(b, d, n, m) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_mark(b, n, m) G_STMT_START {} G_STMT_END
 /* Optimise the whole call out */
 #if defined(G_HAVE_ISO_VARARGS)
-#define gdk_profiler_add_markf(b, d, n, m, ...)
-#define gdk_profiler_end_markf(b, n, m, ...)
+#define gdk_profiler_add_markf(b, d, n, m, ...) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_markf(b, n, m, ...) G_STMT_START {} G_STMT_END
 #elif defined(G_HAVE_GNUC_VARARGS)
-#define gdk_profiler_add_markf(b, d, n, m...)
-#define gdk_profiler_end_markf(b, n, m...)
+#define gdk_profiler_add_markf(b, d, n, m...) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_markf(b, n, m...) G_STMT_START {} G_STMT_END
 #else
 /* no varargs macro support; the call will have to be optimised out by the compiler */
 #endif
 
 #define gdk_profiler_define_counter(n, d) 0
 #define gdk_profiler_define_int_counter(n, d) 0
-#define gdk_profiler_set_counter(i, v)
-#define gdk_profiler_set_int_counter(i, v)
+#define gdk_profiler_set_counter(i, v) G_STMT_START {} G_STMT_END
+#define gdk_profiler_set_int_counter(i, v) G_STMT_START {} G_STMT_END
 #endif
 
 G_END_DECLS